#include <stdio.h>

int main()
{
	int hour_minute,pass,out;
	int hour,minute;
	scanf("%d %d", &hour_minute, &pass);
	hour = hour_minute/100;
	minute = hour_minute - hour*100;
	out = (pass + hour*60 + minute)/60*100 +(pass + hour*60 + minute)%60;
	printf("%d", out);
	return 0; 
}

